/*
 *  Copyright 2010 yura.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.opu.doc2db.document.datadocument;

import java.util.Arrays;

/**
 *
 * @author yura
 */
public class SimpleDocumentGenerator {

    /**
     *  Create Table object, without specific properties,
     * from array of TableRow
     *
     * @param t TableRow array
     * @return Table object, created from array of TableRow
     */
    public static Table toTable(TableRow... t){
        return new Table(Arrays.asList(t));
    }

    /**
     *  Create TableRow object, without specific properties,
     * from array of TableCell
     *
     * @param t TableCell array
     * @return TableRow object, created from array of TableCell
     */
    public static TableRow toRow(TableCell... t){
        return new TableRow(Arrays.asList(t));
    }

    /**
     *  Create TableRow object, with specific metrics,
     * from array of TableCell
     *
     * @param m cell metrics
     * @param t TableCell array
     * @return TableRow object, created from array of TableCell
     */
    public static TableRow toRow(Metric<Integer> m, TableCell... t){
        return new TableRow(Arrays.asList(t), m);
    }

    /**
     *  Create TableCell object, without specific properties,
     * from array of TextParagraph
     *
     * @param t TextParagraphs array
     * @return TableCell object, created from array of TextParagraph
     */
    public static TableCell toCel(TextParagraph... t){
        return new TableCell(Arrays.asList(t));
    }

    /**
     *  Create TableCell object, with specific metric,
     * from array of TextParagraph
     *
     * @param m cell metrics 
     * @param t TextParagraphs array
     * @return TableCell object, created from array of TextParagraph
     */
    public static TableCell toCel(Metric<Integer> m, TextParagraph... t){
        return new TableCell(Arrays.asList(t), m);
    }

    /**
     *  Create TextParagraph object, without specific properties,
     * from array of strings
     *
     * @param t string array
     * @return TextParagraph object, created from array of strings
     */
    public static TextParagraph toPar(String... t){
        return new TextParagraph(Arrays.asList(textToBlock(t)));
    }

    /**
     *  Create array of TextBlock object, without specific properties,
     * from array of strings
     *
     * @param t string array
     * @return array of TextBlock object, created from array of strings
     */
    public static TextBlock[] textToBlock(String... t){
        TextBlock[] b = new TextBlock[t.length];
        for (int i = 0; i < b.length; i++) {
            b[i] = new TextBlock(t[i]);
        }
        return b;
    }
}
